<template>
	<view class="ecologicalReport">
		<!-- ==== 土壤监测 ==== -->
		<soilReport :ids="ReportDate[testingType].id" :soilData="ReportDate[testingType].objectDate" v-if="testingType == 1"></soilReport>
		<!-- ==== 水质监测 ==== -->
		<waterQualityReport :ids="ReportDate[testingType].id" :waterQualityData="ReportDate[testingType].objectDate" v-if="testingType == 2"></waterQualityReport>
		<!-- ==== 植被监测 ==== -->
		<vegetationReport :ids="ReportDate[testingType].id" :vegetationData="ReportDate[testingType].objectDate" v-if="testingType == 3"></vegetationReport>
		<!-- ==== 植被监测 ==== -->
		<microorganismReport :ids="ReportDate[testingType].id" :microorganismData="ReportDate[testingType].objectDate" v-if="testingType == 4"></microorganismReport>
	</view>
</template>

<script>
import soilReport from '../components/soilReport.vue';
import waterQualityReport from '../components/waterQualityReport.vue';
import vegetationReport from '../components/vegetationReport.vue';
import microorganismReport from '../components/microorganismReport.vue';
export default {
	name: 'ecologicalReport',
	data() {
		return {
			// 土质详情
			ReportDate: {
				1: {
					id: 0,
					objectDate: null
				},
				2: {
					id: 0,
					objectDate: null
				},
				3: {
					id: 0,
					objectDate: null
				},
				4: {
					id: 0,
					objectDate: null
				}
			},
			testingType: 0,
			// 检测类目
			testingTypeName: {
				1: '土壤指数',
				2: '水质指数',
				3: '植被指数',
				4: '微生物指数'
			},
			testingTypePOST: {
				1: 'getSoilMessById',
				2: 'waterMapById',
				3: 'vegetationBySampleId',
				4: 'microbialDataById'
			}
		};
	},
	onLoad: function(options) {
		if (options) {
			uni.setNavigationBarTitle({
				title: this.testingTypeName[options.testingType]
			});
			this.testingType = parseInt(options.testingType);
			let objs = null;
			this.ReportDate[this.testingType].id = options.id;
			if (this.testingType == 1) {
				objs = { id: parseInt(this.ReportDate[this.testingType].id) };
			}
			if (this.testingType == 2) {
				objs = { monitorId: this.ReportDate[this.testingType].id };
			}
			if (this.testingType == 3) {
				objs = { sample_id: this.ReportDate[this.testingType].id };
			}
			if (this.testingType == 4) {
				objs = { monitorId: this.ReportDate[this.testingType].id };
			}
			this.getMap(objs);
		}
	},
	methods: {
		/**
		 * 获取详情
		 * */
		getMap(datas) {
			const testingType = this.testingType;
			let upDate = {
				url: '',
				method: 'GET',
				data: datas
			};
			if (testingType == 1) {
				upDate.url = `${this.config[this.testingTypePOST[testingType]]}?id=${datas.id}`;
			}
			if (testingType == 2) {
				upDate.url = `${this.config[this.testingTypePOST[testingType]]}?monitorId=${datas.monitorId}`;
			}
			if (testingType == 3) {
				upDate.url = `${this.config[this.testingTypePOST[testingType]]}?sample_id=${datas.sample_id}`;
			}
			if (testingType == 4) {
				upDate.url = `${this.config[this.testingTypePOST[testingType]]}?monitorId=${datas.monitorId}`;
			}
			this.$$.request(upDate, true, true).then(res => {
				console.log(res.data);
				this.ReportDate[testingType].objectDate = res.data;
			});
		}
	},
	components: {
		soilReport,
		waterQualityReport,
		vegetationReport,
		microorganismReport
	}
};
</script>

<style lang="scss" scoped>
/* 
	 "app-plus": {
	 	"background": "#F5F5F5"
	 }
	 */
// #ifdef H5
page {
	background-color: #f4f4f4;
}
// #endif
.ecologicalReport {
}
</style>
